<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
  <style>
    .active {
      color: red;
    }
  </style>
</head>

<body>
  <!-- 需求：点击列表中哪一项，那么该项文字变成红色 -->
  <div id="app">
    <ul>
      <!-- <li v-for="(变量,index索引) in 数组"></li> -->
      <li v-for="(item,index) in movies" :class="count==index? 'active':'' " @click="changeColor(index)"> {{ item }} </li>
    </ul>
  </div>

  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        count: -1,
        movies: ['海王', '海尔兄弟', '火影忍者', '进击的巨人']
      },
      methods: {
        changeColor: function (index) {
          this.count = index;
        }
      }
    });
  </script>
</body>

</html>